package com.gxa.shop.service.cart.Impl;

import com.gxa.shop.bean.pojo.Cart;
import com.gxa.shop.bean.vo.CartVo;
import com.gxa.shop.dao.cart.CartDao;
import com.gxa.shop.dao.cart.Impl.CartDaoImpl;
import com.gxa.shop.service.cart.CartService;

import java.util.Collections;
import java.util.List;

/**
 * com.gxa.shop.service.cart.Impl
 * User: 刁彦侨
 * Date: 2024/12/19 15:53
 * motto:   逆水行舟不进则退
 * Description:
 * Version: V1.0
 */
public class CartServiceImpl implements CartService {
    private CartDao cartDao = new CartDaoImpl();
    @Override
    public List<CartVo> findById(String id) {
        return cartDao.findById(id);
    }

    @Override
    public boolean addCart(Cart cart) {
        return cartDao.insert(cart)>0;
    }

    @Override
    public boolean deleteCart(Integer userId, Integer productId) {
        return cartDao.deleteById(userId,productId)>0;
    }

    @Override
    public boolean deleteAllCart(Integer userId) {
        return cartDao.deleteByUserId(userId)>0;
    }

    @Override
    public boolean updateCart(Cart cart) {
        return cartDao.update(cart)>0;
    }
}
